{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "0",
   "metadata": {},
   "source": [
    "# CONFIG \n",
    "\n",
    "You have 2 ways of configuring gdsfactory:\n",
    "\n",
    "1. Use `.env` files with CONFIG variables\n",
    "\n",
    "gdsfactory can store settings in a `.env` file in the current directory or any parent directories.\n",
    "\n",
    "You can create a `.env` file in this directory, restart the notebook and see what CONFIG values you are getting.\n",
    "\n",
    "```python\n",
    "difftest_ignore_cell_name_differences=True\n",
    "difftest_ignore_sliver_differences=False\n",
    "difftest_ignore_label_differences=False\n",
    "layer_error_path=[1000, 0]\n",
    "max_cellname_length=99\n",
    "kfactory_logfilter_regex='^KLayout GUI version'\n",
    "kfactory_cell_overwrite_existing=True\n",
    "```\n",
    "\n",
    "\n",
    "2. You can import CONF at the beginning of your script and then overwrite any settings.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1",
   "metadata": {},
   "outputs": [],
   "source": [
    "import gdsfactory as gf\n",
    "\n",
    "gf.CONF"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2",
   "metadata": {},
   "outputs": [],
   "source": [
    "gf.CONF.max_cellname_length = 9  # Making the cell name ridiculously short.\n",
    "c1 = gf.Component(\"Example_long_name_123456789\")\n",
    "print(c1.name)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3",
   "metadata": {},
   "source": [
    "As you can see the cell names are truncated when writing them to GDS."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4",
   "metadata": {},
   "outputs": [],
   "source": [
    "gdspath = c1.write_gds()\n",
    "c2 = gf.import_gds(gdspath)\n",
    "print(c2.name)"
   ]
  }
 ],
 "metadata": {
  "jupytext": {
   "cell_metadata_filter": "-all",
   "custom_cell_magics": "kql"
  },
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
